<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no"/>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>Hello, World</title>
    <style type="text/css">
        html {
            height: 100%
        }

        body {
            height: 100%;
            margin: 0px;
            padding: 0px
        }

        #container {
            height: 100%
        }
    </style>
    <!--v3.0版本的引用方式：src="http://api.map.baidu.com/api?v=3.0&ak=您的密钥"-->
    <script type="text/javascript"
            src="http://api.map.baidu.com/api?v=3.0&ak=vVaRzGOFPO9U1CHR92fOSeBPaCzyCCg9"></script>
</head>

<body>
<div id="container"></div>
<!-- 引入组件库 -->
<script src="../js/vue.js"></script>
<script src="../plugins/elementui/index.js"></script>
<script type="text/javascript" src="../js/jquery.min.js"></script>
<script src="../js/axios-0.18.0.js"></script>
<script type="text/javascript">
    var vue = new Vue({
        el: '#container',
        data: {
            dataList: [],//当前页要展示地址数据
        },
        mounted() {
            axios.post("/address/findAll.do").then(
                (response) => {
                    this.dataList = response.data.data;
                    // var myGeo = new BMap.Geocoder();
                    var adds = new Array();
                    for (let i = 0; i < this.dataList.length; i++) {
                        var point = new BMap.Point(this.dataList[i].longitude, this.dataList[i].latitude);
                        adds.push(point);
                    }
                    for (let i = 0; i < adds.length; i++) {
                        var marker = new BMap.Marker(adds[i]);
                        map.addOverlay(marker);
                        marker.setLabel(new BMap.Label(this.dataList[i].company_address, {offset: new BMap.Size(20, -10)}));
                    }
                }
            )
        }
    });

    // 创建地图实例
    var map = new BMap.Map("container");
    // 创建点坐标
    var point = new BMap.Point(114.333, 30.555);
    // 初始化地图，设置中心点坐标和地图级别
    map.centerAndZoom(point, 13);
    map.enableScrollWheelZoom(true);
    map.addControl(new BMap.NavigationControl());
    map.addControl(new BMap.ScaleControl());
    map.addControl(new BMap.OverviewMapControl());
    map.addControl(new BMap.MapTypeControl());
    map.setCurrentCity("武汉"); // 仅当设置城市信息时，MapTypeControl的切换功能才能可用

</script>
</body>
</html>